package cn.cdeden.knowledge.dubbo;

import cn.cdeden.common.oss.enumd.OssBucketOneEnum;
import cn.cdeden.common.oss.enumd.OssModuleOperate;
import cn.cdeden.common.oss.enumd.OssModuleType;
import cn.cdeden.knowledge.domain.FileTemplateTree;
import cn.cdeden.knowledge.domain.dto.FileTemplateTreeDto;
import cn.cdeden.resource.api.OssUploadService;
import cn.cdeden.resource.api.RemoteFileService;
import cn.cdeden.resource.api.domain.*;
import cn.cdeden.system.api.RemoteUserService;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *
 * @author Administrator
 * @date 2025/1/8 9:28
 * @describe:
 **/

@Slf4j
@Service
@RequiredArgsConstructor
@DubboService(group = "temporary" ,version = "1.0.0")
public class OssUploadTemporaryServiceImpl implements OssUploadService {



    @DubboReference(check = false)
    private final RemoteFileService remoteFileService;

    @Override
    public RemoteFile getFileDataInfo(String moduleId, Long userId, JSONObject info, OssModuleOperate operate) {


        RemoteFile remoteFile = remoteFileService.selectById(moduleId);
        if(!remoteFile.getModuleType().equals(OssBucketOneEnum.TEMPORARY_FILES.getCode())){
            throw new RuntimeException("不是临时文件，不允许访问");
        }
        return remoteFile;
    }

    @Override
    public RemoteOssUpload verifyData(RemoteOssUpload info, Long userId) {
        return info;
    }

    @Override
    public RemoteFilesBucketPath upload(RemoteFilesUpload upload, Long userId) {
        return null;
    }

    @Override
    public List<RemoteFilesDownload> downloadFile(List<String> idList, Long userId, JSONObject jsonObject) {
        return List.of();
    }
}
